<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="job" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{jobHome.managed ? 'Edit' : 'Add'} Job</f:facet>


            <s:decorate id="jobnameField" template="layout/edit.xhtml">
                <ui:define name="label">Jobname</ui:define>
                <h:inputTextarea id="jobname"
                               cols="80"
                               rows="3"
                           disabled="#{jobHome.managed}"
                           required="true"
                              value="#{jobHome.instance.jobname}"/>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{jobHome.persist}"
                       disabled="#{!jobHome.wired}"
                       rendered="#{!jobHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{jobHome.update}"
                       rendered="#{jobHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{jobHome.remove}"
                      immediate="true"
                       rendered="#{jobHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Job.xhtml"
                rendered="#{jobHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty jobFrom ? 'JobList' : jobFrom}.xhtml"
                rendered="#{!jobHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Timeentries">
        <h:form styleClass="association" id="timeentriesChildren">

            <h:outputText value="There are no timeentries associated with this job."
                       rendered="#{empty jobHome.timeentries}"/>

            <rich:dataTable value="#{jobHome.timeentries}"
                           var="_timeentry"
                      rendered="#{not empty jobHome.timeentries}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="timeentriesTable">
                <rich:column sortBy="#{_timeentry.timeentryid}">
                    <f:facet name="header">Timeentryid</f:facet>
                    <h:outputText value="#{_timeentry.timeentryid}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_timeentry.startdatetime}">
                    <f:facet name="header">Startdatetime</f:facet>
                    <h:outputText value="#{_timeentry.startdatetime}">
                        <s:convertDateTime type="date" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_timeentry.enddatetime}">
                    <f:facet name="header">Enddatetime</f:facet>
                    <h:outputText value="#{_timeentry.enddatetime}">
                        <s:convertDateTime type="date" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{jobHome.managed}" id="timeentries">
        <div class="actionButtons">
            <s:button id="addtimeentry"
                   value="Add timeentry"
                    view="/TimeentryEdit.xhtml"
             propagation="none">
                 <f:param name="jobJobname"
                         value="#{jobHome.instance.jobname}"/>
                 <f:param name="timeentryFrom" value="Job"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Feedbacks">
        <h:form styleClass="association" id="feedbacksChildren">

            <h:outputText value="There are no feedbacks associated with this job."
                       rendered="#{empty jobHome.feedbacks}"/>

            <rich:dataTable value="#{jobHome.feedbacks}"
                           var="_feedback"
                      rendered="#{not empty jobHome.feedbacks}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="feedbacksTable">
                <rich:column sortBy="#{_feedback.feedbackid}">
                    <f:facet name="header">Feedbackid</f:facet>
                    <h:outputText value="#{_feedback.feedbackid}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_feedback.text}">
                    <f:facet name="header">Text</f:facet>
                    <h:outputText value="#{_feedback.text}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{jobHome.managed}" id="feedbacks">
        <div class="actionButtons">
            <s:button id="addfeedback"
                   value="Add feedback"
                    view="/FeedbackEdit.xhtml"
             propagation="none">
                 <f:param name="jobJobname"
                         value="#{jobHome.instance.jobname}"/>
                 <f:param name="feedbackFrom" value="Job"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
